home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Extensions / time.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-13  |  457 b   |  25 lines

  1. #include <stk.h>
  2. #include <sys/types.h>
  3. #include <sys/time.h>
  4. #include <time.h>
  5.  
  6. static PRIMITIVE get_time(void)
  7. {
  8.   return STk_makeinteger((long) time(NULL));
  9. }
  10.  
  11. static PRIMITIVE time_string(void)
  12. {
  13.   time_t t= time(NULL);
  14.   char *s;
  15.  
  16.   s = ctime(&t); s[24] = '\0';
  17.   return STk_makestring(s);
  18. }
  19.  
  20. PRIMITIVE STk_init_time(void)
  21. {
  22.   STk_add_new_primitive("get-time",       tc_subr_0, get_time);
  23.   STk_add_new_primitive("time-string", tc_subr_0, time_string);
  24. }
  25.